//
//  RW_PlaySingleCollectionReusableView.m
//  SleepApp
//
//  Created by chuangqi on 2021/4/1.
//  Copyright © 2021 RiceWang. All rights reserved.
//

#import "RW_PlaySingleCollectionReusableView.h"
#import "RW_PlayerViewController.h"
#import "RW_PushPlayersTools.h"

@interface RW_PlaySingleCollectionReusableView ()
@property (nonatomic,strong) UIButton *title_button;
@end
@implementation RW_PlaySingleCollectionReusableView
-(void)bind_section_data:(WLBaseCollectionViewLayerSection *)sender{
    if ([sender.headerData isKindOfClass:RW_PlaySingleCollectionReusableViewModel.class]){
        if (![self.model isEqual:sender.headerData]){
            self.model = sender.headerData;
        }
    }
}
-(void)setModel:(RW_PlaySingleCollectionReusableViewModel *)model{
    _model = model;
}

-(void)bind_delegate:(id)sender{
    
}

- (instancetype)init{
    self = [super init];
    if (self) {
        [self initView];
    }
    return self;
}
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self initView];
    }
    return self;
}

- (void)initView{
    self.backgroundColor = UIColor.whiteColor;
    [self addSubview:self.title_button];
    [self.title_button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self);
        make.centerX.mas_equalTo(self);
//        make.left.mas_equalTo(self).mas_offset(10);
    }];
}


-(void)push_pay:(UIButton *)sender{
    if (self.model.singleModel){
        [RW_PushPlayersTools pushSingleId:self.model.singleModel.xid fromVc:[self viewController_wl]];
    } else if (self.model.userSingleModel){
        [RW_PushPlayersTools pushUserSingleId:self.model.userSingleModel.xid fromVc:[self viewController_wl]];
    }
}

#pragma mark --懒加载
-(UIButton *)title_button{
    if (!_title_button){
        _title_button = [[UIButton alloc]init];
        [_title_button setTitle:@"播放全部" forState:UIControlStateNormal];
        [_title_button setTitleColor:HexColor(@"444444") forState:UIControlStateNormal];
        _title_button.titleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
        [_title_button addTarget:self action:@selector(push_pay:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _title_button;
}
@end


@implementation RW_PlaySingleCollectionReusableViewModel

@end
